package demo13;

/**
 * @program: qy158
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-01 09:20
 **/
public class TestJoin {
    public static void main(String[] args) throws InterruptedException {
        JoinDemo t1 = new JoinDemo();
        t1.start();
        JoinDemo t2 = new JoinDemo();
        t2.start();

        //main允许t1下加入，只有t1线程执行完毕后主线程才会执行。
        t1.join();
        t2.join();
        for (int i = 0; i < 20; i++) {
            System.out.println("main===============" + i);
        }
    }
}

class JoinDemo extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName() + "~~~~~~~~~~~~~" + i);
        }
    }
}